package cn.edu.scau.sec.zhangsan.client;

import cn.edu.scau.sec.zhangsan.composite.consist.ConsistAtomTestCase;
import cn.edu.scau.sec.zhangsan.composite.consist.ConsistTestCase;
import cn.edu.scau.sec.zhangsan.composite.consist.ConsistTestSuite;
import cn.edu.scau.sec.zhangsan.composite.safe.SafeAtomTestCase;
import cn.edu.scau.sec.zhangsan.composite.safe.SafeTestCase;
import cn.edu.scau.sec.zhangsan.composite.safe.SafeTestSuite;

public class CompositeClient {

	public static void main(String[] args) {
//		safeTest();
		consistTest();
		
		
		
		
	}

	private static void safeTest() {
		SafeTestCase atomTestCase1 = new SafeAtomTestCase(2, 1, 1);
		if(atomTestCase1.test()) {
			System.out.println("测试通过");
		}else {
			System.out.println("测试没有通过");
		}
		
		SafeTestCase atomTestCase2 = new SafeAtomTestCase(3, 2, 1);
		if(atomTestCase2.test()) {
			System.out.println("测试通过");
		}else {
			System.out.println("测试没有通过");
		}
		
		SafeTestSuite compositeTestCase1 = new SafeTestSuite();
		compositeTestCase1.addChild(atomTestCase1);
		compositeTestCase1.test();
		
		System.out.println("添加第一个测试用例后组合测试用例测试完成");
		
		compositeTestCase1.addChild(atomTestCase2);
		compositeTestCase1.test();
		
		System.out.println("继续添加第二个组合测试用例测试完成");
	}
	
	private static void consistTest() {
		ConsistTestCase atomTestCase1 = new ConsistAtomTestCase(2, 1, 1);
		if(atomTestCase1.test()) {
			System.out.println("测试通过");
		}else {
			System.out.println("测试没有通过");
		}
		
		ConsistTestCase atomTestCase2 = new ConsistAtomTestCase(3, 2, 1);
		if(atomTestCase2.test()) {
			System.out.println("测试通过");
		}else {
			System.out.println("测试没有通过");
		}
		
		ConsistTestCase compositeTestCase1 = new ConsistTestSuite();
		compositeTestCase1.addChild(atomTestCase1);
		compositeTestCase1.test();
		
		System.out.println("添加第一个测试用例后组合测试用例测试完成");
		
		compositeTestCase1.addChild(atomTestCase2);
		compositeTestCase1.test();
		
		System.out.println("继续添加第二个组合测试用例测试完成");
	}

}
